package Test;

import java.util.Scanner;

public class Test11 {
    //把字符串转换成整数
    public static int Short(String str){
        char[] ch = str.toCharArray();
        if(ch == null || ch.length ==0){
            return 0;
        }
        int sum = 0;
        int flg = 1;
        if(ch[0] == '-'){
            flg = -1;
            ch[0] = '0';
        }else if(ch[0] == '+'){
            flg = 1;
            ch[0] = '0';
        }
        for (int i = 0; i < ch.length; i++) {
           if(ch[i] < '0' || ch[i] > '9'){
              sum = 0;
              break;
           }
            sum = sum*10 + ch[i] - '0';
        }
        return flg*sum;
    }
    public static void main(String[] args) {
        String str = "-123456";
        int ret = Short(str);
        System.out.println(ret);
    }
    //不要二问题
   /* public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int W = scanner.nextInt();
        int H = scanner.nextInt();
        int [][] array = new int[W][H];
        int count = 0;
        for (int i = 0; i < W; i++) {
            for (int j = 0; j < H; j++) {
                if(array[i][j] == 0){
                    count++;
                    if(i+2 < W){
                        array[i+2][j] = 1;
                    }
                    if(j+2 < H){
                        array[i][j+2] = 1;
                    }
                }
            }
        }
        System.out.println(count);*/
    }
